package com.dq;

import com.dq.common.URL;
import com.dq.protocol.HttpServer;
import com.dq.register.LocalRegister;
import com.dq.register.MapRemoteRegister;

/**
 * @ClassName Provider
 * @Description 提供类 配置 接收网络请求 启动Tomcat
 * @Author DuX1aoQiang
 * @Date 2023/5/24 11:31
 * @Version 1.0
 */
public class Provider {
    public static void main(String[] args) {
        // 本地注册 一个接口注册2个实现类 利用版本区分
        LocalRegister.register(HelloService.class.getName(), "1.0", HelloServiceImpl.class);
        LocalRegister.register(HelloService.class.getName(), "2.0", HelloServiceImpl2.class);

        //远程Map注册
        URL url = new URL("localhost", 8080);
        MapRemoteRegister.register(HelloService.class.getName(), url);

        //启动Tomcat时自动 注册实现类
        HttpServer httpServer = new HttpServer();
        httpServer.start(url.getHostname(), url.getPort());
    }
}
